//
//  WorkingResultData.m
//  WorkingResult
//
//  Created by 河野 智遵 on 11/08/21.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "WorkingResultData.h"
#import "Task.h"

@implementation WorkingResultData

- (WorkingResultData*)init
{
    [super init];
    tasks_ = [NSMutableArray array];
    [tasks_ retain];
    return self;
}

- (void)addTask:(Task*) task
{
    Task* t = [[Task alloc] initWithText:task.text color:task.color];
    [tasks_ addObject:t];
}

- (void)updateTask:(Task*) task index:(NSInteger) index
{
    Task* t = [[Task alloc] initWithText:task.text color:task.color];
    [tasks_ replaceObjectAtIndex:index withObject:t];
}

- (NSInteger) getTaskCount
{
    return [tasks_ count];
}

- (NSArray*)getAllTasks
{
    return [tasks_ subarrayWithRange:NSMakeRange(0, [tasks_ count])];
}

- (Task*)taskAtIndex:(NSInteger)index
{
    Task* t = [tasks_ objectAtIndex:index];
    return [[[Task alloc] initWithText:t.text color:t.color] autorelease];
}

- (void)deleteAtIndex:(NSInteger)index
{
    [tasks_ removeObjectAtIndex:index];
}

- (void)release
{
    [tasks_ release];
    [super release];
}

@end
